package cc.realxyq.demo.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.FactoryBean;

/**
 * @author kwhan
 * @date 2022年01月08日 14:16
 */
@Slf4j
public class ColorFactoryBean implements FactoryBean<Color> {
    @Override
    public Color getObject() throws Exception {
        log.info("ColorFactoryBean工厂bean调用了 getObject 方法，获取 Color对象");
        return new Red("红色：通过FactoryBean注入的");
    }

    @Override
    public Class<?> getObjectType() {
        return Color.class;
    }

    @Override
    public boolean isSingleton() {
        return FactoryBean.super.isSingleton();
    }
}
